package P112_NonInspectedException;

import org.junit.Test;

/**
 * @ClassName : NonInspectedException
 * @Description : 受检异常尽可能转换成非受检异常
 * @Author : wukj1
 * @Date: 2022/5/4
 **/
public class NonInspectedException {

    //非受检异常指的是：RuntimeException类 和 Error类及其子类
    //受检异常指的是：包括非受检异常之外的其他的异常类

    //受检异常的不足之处： 1、受检异常使接口声明脆弱 2、使代码的可读性降低 3、受检异常增加了代码的工作量

    @Test
    public void test(){
        UserImpl user = new UserImpl();
        try {
            user.changePassword();
        } catch (MySecurityException | RejectChangedException e) {
            e.printStackTrace();
        }
    }

}

interface User{
    public void changePassword() throws MySecurityException,RejectChangedException;
}

class UserImpl implements User{

    @Override
    public void changePassword() throws MySecurityException,RejectChangedException{

    }

}

class MySecurityException extends Exception {

}

class RejectChangedException extends Exception{

}
